//#include "iniparser.h"

//char key[MAXSTRLEN];

//#define REAL float

#if !defined(TRUE) || !defined(FALSE)
enum {FALSE, TRUE};
#endif

#define SKIPBLANK         while(po[0] & (po[0]==' ' || po[0]=='\t')) po++; \
                          if (!po[0]) { \
                             i++;      \
                             po=argv[i]; \
                          }
enum RC{OK, APPLICATION_RC, STRDUP_RC, MALLOC_RC, FOPEN_RC, POPEN_RC, FGETS_RC,
        SOCKET_RC, SEND_RC, RECV_RC, LOCK_RC, UNLOCK_RC, MAKEMATR_RC,
        MAKEVECT_RC,FINDLOG_RC,FREAD_RC, FSTAT_RC, MMAP_RC};


#define MAXSTRLEN 1024
#define MAXFILENAME 256
#define INVALID_INT -999999
#define INVALID_REAL -1.e7
#define INVALID_STR NULL



#define READINTFI(v,s) snprintf(key,sizeof(key),"%s:%s","INPUTDATA",(s)); \
                          (v)=iniparser_getint(ini, key, INVALID_INT); \
                          if((v)==INVALID_INT) { \
                            writelog(TRUE,APPLICATION_RC, \
                                     "Invalid value for key <%s> from input file %s\n", \
                                     key, inputfile); \
                          }

#define READREALFI(v,s)  snprintf(key,sizeof(key),"%s:%s","INPUTDATA",(s)); \
                            (v)=(REAL)iniparser_getdouble(ini, key, INVALID_REAL);\
                            if((v)==(REAL)INVALID_REAL) { \
                              writelog(TRUE,APPLICATION_RC,\
                                       "Invalid value for key <%s> from input file %s\n",\
                                       key, inputfile); \
                            }

#define READSTRFI(v,s)  snprintf(key,sizeof(key),"%s:%s","INPUTDATA",(s)); \
							char* temp=iniparser_getstring(ini, key, INVALID_STR);\
							if(temp==INVALID_STR) { \
							  writelog(TRUE,APPLICATION_RC,\
										"Invalid value for key <%s> from input file %s\n",\
										key, inputfile); \
							}else{ sscanf(temp,"%s",(v)); }


#define DEVICEREADINTFI(v,s) snprintf(key,sizeof(key),"%s:%s","CUDA",(s)); \
                          (v)=iniparser_getint(ini, key, INVALID_INT); \
                          if((v)==INVALID_INT) { \
                            writelog(TRUE,APPLICATION_RC, \
                                     "Invalid value for key <%s> from input file %s\n", \
                                     key, inputfile); \
                          }

void writelog(int, int, const char *fmt, ...);
void *Malloc(int);
void Free(void *);
FILE *Fopen(const char *, const char *);
void *Mmap(const char *, const char *);
char *Strdup(char *);
size_t Fread (void * ptr, size_t size, size_t count, FILE * stream);
bool pow_of_two(int i);


